<?php
if(isset($_GET["action"])) //check if the request exists
	{
	switch($_GET["action"]) //verify what kind of request is it
		{
		case "add": //the request is an add request
			//perform task
			
			//getting the cart id from the cookie
			$shoppingcart_id = $_COOKIE["shoppingcart_id"];

			//getting the item id from the request
			$item_id = $_GET["item"];

			//getting the quantity of items
			$item_quantity = $_GET["quantity"];
		
			//perform the mysql query to link the two elements inside DB
			mysql_query("INSERT INTO REL (ID_CART, ID_ITEM, AMOUNT) VALUES ('$shoppingcart_id', '$item_id', '$item_quantity')");
		break;
		
		case "delete":
		
			//getting the cart id from the cookie
			$shoppingcart_id = $_COOKIE["shoppingcart_id"];

			//getting the item id from the request
			$item_id = $_GET["item"];
			
			//delete the link between the cart and the item
			mysql_query("DELETE FROM rel WHERE ID_CART = '$shoppingcart_id' AND ID_ITEM = '$item_id'");

		break;
		}
	}
?>